/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.model;

import java.io.Serializable;

/**
 * Answer origin.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 * @since 10-jun-2009 13:24:37
 */
public enum AnswerOrigin implements IntegerEnumeration, Serializable {
/**
   * Loaded from an external file or data source.
   */
	LOAD(1, "answer.origin.load"), 
/**
   * Recorded from the web.
   */
	WEB(2, "answer.origin.web");
	/**
	 * The identifier.
	 */
	private final int id;

	/**
	 * The key.
	 */
	private final String key;

/**
   * Constructor.
   *
   * @param id  the identifier.
   * @param key the key.
   */
	AnswerOrigin(int id, String key) {
		this.id = id;
		this.key = key;
	}

	/**
	 * Retrieves the identifier.
	 *
	 * @return the identifier.
	 */
	public int getId() {
		return id;
	}

	/**
	 * Retrieves the key.
	 *
	 * @return the key.
	 */
	public String getKey() {
		return key;
	}

	/**
	 * Retrieves a value by its identifier.
	 *
	 * @param id the id.
	 *
	 * @return the origin.
	 */
	public static AnswerOrigin getById(int id) {
		switch(id) {
			case 1:
				return LOAD;

			case 2:
				return WEB;
		}

		return null;
	}
}
